//
//  PlayVideoController.m
//  Only Love
//
//  Created by xalo on 16/5/9.
//  Copyright © 2016年 海城. All rights reserved.
//

#import "PlayVideoController.h"
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
@interface PlayVideoController ()

@property (strong,nonatomic)AVPlayerViewController *playerViewController;

@end
@implementation PlayVideoController

- (void)viewDidLoad{
    
    [super viewDidLoad];
    NSDictionary *dic = self.receiveArray[self.indexPath.row];
    NSURL *url = [NSURL fileURLWithPath:dic[@"videoPath"]];
    AVPlayerItem *playItem = [AVPlayerItem playerItemWithURL:url];
    self.playerViewController.player = [AVPlayer playerWithPlayerItem:playItem];
    
    [self  addChildViewController:self.playerViewController];
    [self.view addSubview:self.playerViewController.view];
    
}

#pragma mark 属性的懒加载
- (AVPlayerViewController *)playerViewController{
    
    if (!_playerViewController) {
        
        _playerViewController = [[AVPlayerViewController alloc] init];
        _playerViewController.view.frame = CGRectMake(0, 0, kWidth, 300);
    }
    return _playerViewController;
}
@end
